// DlgLocationResult.cpp : implementation file
//

#include "stdafx.h"
#include "MotionControlSoftware.h"
#include "DlgLocationResult.h"
#include "afxdialogex.h"
#include "Tool/Tool.h"


// CDlgLocationResult dialog

IMPLEMENT_DYNAMIC(CDlgLocationResult, CDialogEx)

CDlgLocationResult::CDlgLocationResult(CWnd* pParent /*=NULL*/)
	: CDialogEx(CDlgLocationResult::IDD, pParent)
	, m_dLocationRet1X(0)
	, m_dLocationRet1Y(0)
	, m_dLocationRet2X(0)
	, m_dLocationRet2Y(0)
	, m_dLocationRet1R(0)
	, m_dLocationRet2R(0)
	, m_dLocationRet3X(0)
	, m_dLocationRet3Y(0)
	, m_dLocationRet4X(0)
	, m_dLocationRet4Y(0)
	, m_dLocationRet3R(0)
	, m_dLocationRet4R(0)
{
	strLocationRet1 = _T("");
	strLocationRet2 = _T("");
}

CDlgLocationResult::~CDlgLocationResult()
{
}

void CDlgLocationResult::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT_Location1X, strLocationRet1);
	DDX_Text(pDX, IDC_EDIT_Location2X, strLocationRet2);
}


BEGIN_MESSAGE_MAP(CDlgLocationResult, CDialogEx)
	ON_BN_CLICKED(IDOK, &CDlgLocationResult::OnBnClickedOk)
END_MESSAGE_MAP()


// CDlgLocationResult message handlers


BOOL CDlgLocationResult::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  Add extra initialization here

	UpdateData(FALSE);
	SetWindowText(m_strWndText);
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}


void CDlgLocationResult::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	if (UpdateData(TRUE))
	{
		int iBegPos = 0;
		int iFind = strLocationRet1.Find(_T(","),iBegPos);
		CString strData = strLocationRet1.Mid(iBegPos,iFind-iBegPos);
		m_dLocationRet1X = CTool::CStringToDouble(strData);

		iBegPos = iFind + 1;
		iFind = strLocationRet1.Find(_T(","),iBegPos);
		strData = strLocationRet1.Mid(iBegPos,iFind-iBegPos);
		m_dLocationRet1Y = CTool::CStringToDouble(strData);

		strData = strLocationRet1.Mid(iFind+1,strLocationRet1.GetLength()-iFind-2);
		m_dLocationRet1R = CTool::CStringToDouble(strData);

		iBegPos = 0;
		iFind = strLocationRet2.Find(_T(","),iBegPos);
		strData = strLocationRet2.Mid(iBegPos,iFind-iBegPos);
		m_dLocationRet2X = CTool::CStringToDouble(strData);

		iBegPos = iFind + 1;
		iFind = strLocationRet2.Find(_T(","),iBegPos);
		strData = strLocationRet2.Mid(iBegPos,iFind-iBegPos);
		m_dLocationRet2Y = CTool::CStringToDouble(strData);

		strData = strLocationRet2.Mid(iFind+1,strLocationRet2.GetLength()-iFind-2);
		m_dLocationRet2R = CTool::CStringToDouble(strData);

	}
	CDialogEx::OnOK();
}
